<%@ page language="java" pageEncoding="UTF-8" buffer="16kb"%>
<%@ include file="/base.jsp"%>
<%@ include file="/module/taglibs.jsp"%>
<%@ include file="/module/nocache.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<%@ include file="/module/js.jsp"%>
<script>
	$(document)
			.ready(
					function() {
						var _form=$("#semesterForm").validate();
						$('#btnBack')
								.click(
										function() {
											document.semesterForm.action = "${basePath}/semesterSummary/semesterSummaryManagerIndex";
											document.semesterForm.submit();
										});
						//保存
						$("#btnSave").click(function() {
							if(_form.form()){
							 if(validateSqxm()){	
								$("#btnSave").attr("disabled","disabled");
								$("#flag").val(1);
								  document.semesterForm.action ="${basePath}/semesterSummary/addManagerSemesterSummary";
								  document.semesterForm.submit();
							 }
							}
						});
					  //保存继续新增
						$("#btnSave2").click(function() {
							if(_form.form()){
								 if(validateSqxm()){
							    $("#flag").val(2);
								$("#btnSave2").attr("disabled","disabled");
								  document.semesterForm.action ="${basePath}/semesterSummary/addManagerSemesterSummary";
								  document.semesterForm.submit()
								 }
							}
						});
						  //取消
						$("#btnSave3").click(function() {
							  layer.confirm("您是否确定取消?", {icon: 3, title:'提示',skin:'layer-ext-moon'}, function(index){
								  $("#btnSave3").attr("disabled","disabled");
								  document.semesterForm.action ="${basePath}/semesterSummary/addSemesterSummaryManagerForward?ismanager="+$("#ismanager").val();
								  document.semesterForm.submit();
							  },function(index){
									layer.close(index);
							  });
								
						});
						  //选择
						$("#div1").dialog({
							width : 'auto',
							height : 'auto',
							bgiframe : true,
							modal : true,
							draggable : true,
							resizable : false,
							title : '选择学生',
							autoOpen : false,
						    buttons : {
						    '取消' : function() {
						    	$(this).dialog('close');
							},
							'确定' : function() {
							  if($("#fromSelect").val()==null||$("#fromSelect").val()==""){
								 layer.alert("必须选择一项", {icon: 6});
								 return false;
							  }else{
							    var formSelect = document.getElementById("fromSelect");
							    var str = [];
							    var num=0;
							    for(i=0;i<formSelect.length;i++){
							        if(formSelect.options[i].selected){
							            //str.push(select[i].value);
							            num++;
							        }
							    }
							    if(num>=2){
							     layer.alert("只能选择一项", {icon: 6});
							      return false;
							    }else{
							    	var result = $.parseJSON('${studentListJson}');
							    	var xsid=$("#fromSelect").val();
									for (var i = 0; i < result.length; i++) {
										if(xsid==result[i].xsid){
										 $("#xh").val(result[i].xh);
										 $("#xm").val(result[i].xm);
										 $("#xb").val(result[i].xb);
										 $("#bjmc").val(result[i].bjmc);
										 $("#zymc").val(result[i].zymc);
										 $("#njmc").val(result[i].njmc);
										 $("#stuid").val(xsid);
										 $("#bjid").val(result[i].bjid);
										 compareListValue(document.getElementById('zzmm'),result[i].zzmm);
										 //$("#name").val($("#fromSelect").find("option:selected").text());
										 // $("#principal").val($("#fromSelect").val());
										 break;
										}
									}
									  $(this).dialog('close');
							    }
							  }							  
							}
						  }
						});
						  
						  
					});
       function validateSqxm(){
    	   var p1=$('input[name="p"]:checked').val();
    	   var p21=$('input[name="p21"]:checked').val();
    	   var p22=$('input[name="p22"]:checked').val();
    	   var bool=false;
    	   if(p1!=null&&p1!=""){
    		   bool=true;
    	   }
    	   if(p21!=null&&p21!=""){
    		   bool=true; 
    	   }
    	   if(p22!=null&&p22!=""){
    		   bool=true; 
    	   }
    	   if(bool==false){
    		   layer.alert("本学期您想申请的先进项目至少选一项", {icon: 6});
    		   return false;
    	   }
    	   return bool;
       }
    function showStudentDiv(){
    	$('#div1').dialog('open');	
    }   
       
   	function optionRadion(){
		  var old = null; //用来保存原来的对象
		    $("input[name='p']").each(function(){//循环绑定事件
		        if(this.checked){
		            old = this; //如果当前对象选中，保存该对象
		        }
		        this.onclick = function(){
		            if(this == old){//如果点击的对象原来是选中的，取消选中
		                this.checked = false;
		                old = null;
		            } else{
		                old = this;
		            }
		        }
		    });
	}
</script>
</head>
<body>
	<form action="#" id="semesterForm" name="semesterForm">
		<input type="hidden" name="token" value="${token}" />
		<input  type="hidden" id="flag" name="flag" value=""/>
		<input  type="hidden" id="ismanager" name="ismanager" value="${ismanager}"/>
		<input type="hidden" id="bzr" name="bzr" value="${ismanager}" />
		<table cellpadding="0" cellspacing="0" border="0" class="table-border"
			width="95%">
			<tr>
				<td class="table-header" colspan="6">期末总结信息</td>
			</tr>
			<tr>
				<td class="table-titleTD" style="width: 12%"><font color="red">*</font>姓名：</td>
				<td class="table-contentTD" style="width: 22%"><input type="text" id="xm" name="xm" value="" placeholder="请输入姓名"   autocomplete="off" readonly="readonly" class="inputText2 required"/>&nbsp;&nbsp;
				<input type="button" id="optionBtn" value="选择" class="inputButton"
					onclick="javascript:showStudentDiv();" readonly="readonly"/>
				<input type="hidden" id="stuid" name="stuid" value=""/>
				</td>
				<td class="table-titleTD"  style="width: 12%">学号：</td>
				<td class="table-contentTD" style="width: 22%"><input type="text" id="xh" name="xh" value="" autocomplete="off" readonly="readonly" class="inputText"></td>
				<td class="table-titleTD" style="width: 12%">性别：</td>
				<td class="table-contentTD" style="width: 22%"><input type="text" id="xb" name="xb" value="" autocomplete="off" readonly="readonly" class="inputText"></td>
			</tr>
			<tr>
				<td class="table-titleTD" style="width: 12%">班级：</td>
				<td class="table-contentTD" style="width: 22%"><input type="text" value="" id="bjmc" name="bjmc" readonly="readonly" class="inputText">
				<input type="hidden" id="bjid" name="bjid" value=""/></td>
				<td class="table-titleTD" style="width: 12%">专业：</td>
				<td class="table-contentTD" style="width: 22%"><input type="text" value="" id="zymc" name="zymc" readonly="readonly" class="inputText"></td>
				<td class="table-titleTD" style="width: 12%">年级：</td>
				<td class="table-contentTD" style="width: 22%"><input type="text" value="" id="njmc" name="njmc" readonly="readonly" class="inputText"></td>
			</tr>
			<tr>
				<td class="table-titleTD" style="width: 12%">学期：</td>
				<td class="table-contentTD" style="width: 22%"><select id="semid" name="semid" class="selectList" placeholder="请选择学期">
						<option value="">请选择</option>
							<c:forEach items="${semesterList}" var="semester">
								<option value="${semester.xqid}">${semester.xqmc}</option>
							</c:forEach>
				</select></td>
				<td class="table-titleTD" style="width: 12%">政治面貌：</td>
				<td class="table-contentTD" style="width: 22%"><select id="zzmm" name="zzmm"  class="selectList" placeholder="请选择政治面貌">
						<option value="">无</option>
						<c:forEach items="${sysCodeList}" var="code">
							<option value="${code.codename}">${code.codename}</option>
						</c:forEach>
				</select></td>
				<td class="table-titleTD" style="width: 12%">担任职务：</td>
				<td class="table-contentTD" style="width: 22%"><select id="drzw" name="drzw" class="selectList" placeholder="请选择担任职务">
				<option value="">请选择</option>
				 <option value="班长">班长</option>
				<option value="副班长">副班长</option>
				<option value="团支书">团支书</option>
				<option value="纪律委员">纪律委员</option>
				<option value="体育委员">体育委员</option>
				<option value="文艺委员">文艺委员</option>
				<option value="生活委员">生活委员</option>
				<option value="卫生委员">卫生委员</option>
				<option value="宣传委员">宣传委员</option>
			    <option value="组织委员">组织委员</option>
				<option value="学习委员">学习委员</option>
				<option value="班主任助理">班主任助理</option>
				<option value="无">无</option>
				</select></td>
			</tr>
			<tr>
			<td class="table-titleTD" colspan="6" style="text-align: left;">*本学期你想申请的先进项目：</td>
			</tr>
			<tr>
			 <td colspan="6" class="table-contentTD" style="color: #000000" >
			  <label><input type="radio" value="三好学生" id="p" name="p" onclick="optionRadion();"/>三好学生</label>
			 <label><input type="radio" value="好学生" id="p" name="p" onclick="optionRadion();"/>好学生</label>
			 <label><input type="radio" value="行为达标生" id="p" name="p" onclick="optionRadion();"/>行为达标生</label>
			 <label><input  type="checkbox" id="p21" name="p21" value="优秀班干部" />优秀班干部</label>
			 <label><input type="checkbox" id="p22" name="p22" value="技能特长生" />技能特长生</label>
			 </td>
			</tr>
			<tr>
			<td class="table-titleTD">本学期取得的各项荣誉：</td>
			<td colspan="5" class="table-contentTD">
			<textarea  id="hdry" name="hdry" style="width: 90%;height: 80px;" placeholder="请输入本学期取得的各项荣誉"></textarea>
			</td>
			</tr>
			<tr>
			<td class="table-titleTD">备注：</td>
			<td colspan="5" class="table-contentTD">
			<textarea  id="remark" name="remark" style="width: 90%;height: 80px;" placeholder="请输入备注"></textarea>
			</td>
			</tr>
		</table>
		<br />
		<table cellpadding="1" cellspacing="1" border="0" align="left">
			<tr>
			   <c:if test="${ismanager==1}">
			  	<kl:permission permisstionList="${permisstionList}" 
						currentUser="${_login_console_user}"
						currentCatalogId="<%=CatalogUtils.getCatalogId(\"XGGL_QMPB_QMZJ_BZR\")%>" key="add"> 
				<td><input type="button" id="btnSave" autocomplete="off"  class="inputButton"
					style="text-align: center;" value="保存" /></td>
				<td><input type="button" id="btnSave2" autocomplete="off"  class="inputButton"
					style="text-align: center;" value="保存并新增" /></td>
				</kl:permission> 
			   </c:if>
				<td><input type="button" id="btnSave3" autocomplete="off"  class="inputButton"
					style="text-align: center;" value="取消" /></td>
				<td><input type="button" id="btnBack" autocomplete="off"  class="inputButton"
					value="返回" style="text-align: center;" /></td>
			</tr>
		</table>
    <div id="div1" style="display: none;">
			<table cellpadding="0" cellspacing="0" border="0" class="table-border">
				  <tr>
				  	 <td style="clear:both; width: 70%">
				  	  <input class="text" name="searchemp" ondblclick="javascript:filterSelectItems('sourseFromSelect2','fromSelect','fromSelect',this.value);"  onkeyup="javascript:filterSelectItems('sourseFromSelect2','fromSelect','fromSelect',this.value);"/><font color="green">在此查找</font> <br/>
				  	   <br/><label style="color:red;">未选中:</label><br/>
				  	   <select name="fromSelect" id="fromSelect" multiple="multiple"  size="1"  multiple="false" style="width:200px; height: 250px;"
							ondblclick="moveField('fromSelect','toSelect');">
											<c:forEach items="${studentList}" var="data">
									       <option value="${data.xsid}">${data.xm}</option>
								          </c:forEach>
						</select>
							<select name="sourseFromSelect2" id="sourseFromSelect2"   multiple="false" style="width: 220px; height: 150px; display: none;" >
										  <c:forEach items="${studentList}" var="data">
									       <option value="${data.xsid}">${data.xm}</option>
								          </c:forEach>
  	    </select>
						
					 </td>
  	              </tr>
			</table>
		</div>

	</form>
</body>
	<script type="text/javascript">
	 compareListValue(document.getElementById('semid'),'${semester.xqid}');
	 if("${msg}"!=""){
	       layer.alert("${msg}", {icon: 6});
	  } 
</script>
</html>
